﻿using System.Net.WebSockets;
using WebSocketApi.Request;

namespace WebSocketApi.SocketHandler
{
    /// <summary>
    /// WebSocket对象管理接口
    /// </summary>
    public abstract class ISocketServiceHandler
    {
        /// <summary>
        /// 连接Socket
        /// </summary>
        /// <param name="socket"></param>
        /// <returns></returns>
        public abstract Task OnConnectedAsync(WebSocket socket);

        /// <summary>
        /// 断开连接的Socket
        /// </summary>
        /// <param name="socket"></param>
        public abstract Task OnDisconnectedAsync(WebSocket socket);

        /// <summary>
        /// 接收文本消息
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public abstract Task ReceiveTextAsync(WebSocket socket, string message);

        /// <summary>
        /// 处理文件流
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="result"></param>
        /// <param name="buffer"></param>
        /// <returns></returns>
        public abstract Task ReceiveFileAsync(WebSocket socket, WebSocketReceiveResult result, byte[] buffer);

        /// <summary>
        /// 单发消息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public abstract Task SendMessageAsync(SingleMessageRequest request);

        /// <summary>
        /// 群发消息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public abstract Task SendGroupMessageAsync(GroupMessageRequest request);

        /// <summary>
        /// 发送全体
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public abstract Task SendMassMessageAsync(MassMessageRequest request);



    }
}
